/* 全局样式 */
:root {
    --primary-color: #667eea;
    --primary-dark: #5a6fd8;
    --secondary-color: #764ba2;
    --background-color: #f8fafc;
    --sidebar-bg: #ffffff;
    --card-bg: #ffffff;
    --text-color: #2d3748;
    --text-light: #718096;
    --border-color: #e2e8f0;
    --shadow-light: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-medium: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-large: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --accent-color: #667eea;
    --error-color: #f56565;
    --success-color: #48bb78;
    --warning-color: #ed8936;
    --info-color: #4299e1;
    --sidebar-width: 280px;
    --sidebar-collapsed-width: 80px;
}

/* 浅色主题变量 */
[data-theme="浅色主题"] {
    --primary-color: #667eea;
    --primary-dark: #5a6fd8;
    --secondary-color: #764ba2;
    --background-color: #f8fafc;
    --sidebar-bg: #ffffff;
    --card-bg: #ffffff;
    --text-color: #2d3748;
    --text-light: #718096;
    --border-color: #e2e8f0;
}

/* 深色主题变量 */
[data-theme="深色主题"] {
    --primary-color: #667eea;
    --primary-dark: #5a6fd8;
    --secondary-color: #764ba2;
    --background-color: #1a202c;
    --sidebar-bg: #2d3748;
    --card-bg: #2d3748;
    --text-color: #f7fafc;
    --text-light: #a0aec0;
    --border-color: #4a5568;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    font-size: 14px;
}

/* 应用容器 */
.app-container {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* 侧边栏样式 */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    box-shadow: var(--shadow-medium);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 1000;
    transition: all 0.3s ease;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar.collapsed .sidebar-nav .nav-item span {
    display: none;
}

.sidebar.collapsed .sidebar-footer {
    padding: 1rem 0.5rem;
}

.sidebar.collapsed .theme-selector select {
    display: none;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo i {
    font-size: 1.5rem;
    color: var(--primary-color);
}

.logo h1 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-color);
    margin: 0;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
}

.sidebar-toggle:hover {
    background-color: var(--border-color);
    color: var(--text-color);
}

/* 侧边栏导航 */
.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 2rem;
}

.nav-section h3 {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-light);
    padding: 0 1.5rem;
    margin-bottom: 0.5rem;
}

.nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background-color: var(--border-color);
    color: var(--primary-color);
}

.nav-item.active {
    background-color: rgba(102, 126, 234, 0.1);
    color: var(--primary-color);
    border-left-color: var(--primary-color);
}

.nav-item i {
    width: 1.25rem;
    margin-right: 0.75rem;
    font-size: 1rem;
}

.nav-item span {
    font-weight: 500;
}

/* 侧边栏底部 */
.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.theme-selector {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.theme-selector label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-light);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.theme-selector select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    background-color: var(--card-bg);
    color: var(--text-color);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.theme-selector select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* 主内容区域 */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: all 0.3s ease;
}

.content-wrapper {
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

/* 页面头部 */
.page-header {
    margin-bottom: 2rem;
}

.page-header h2 {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.page-header h2 i {
    color: var(--primary-color);
}

.page-description {
    color: var(--text-light);
    font-size: 1rem;
    margin: 0;
}

/* 内容区域样式 */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* 布局样式 */
.content-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

.single-card-layout {
    display: flex;
    justify-content: center;
}

.single-card-layout .card {
    width: 100%;
    max-width: 800px;
}

/* 卡片样式 */
.card {
    background-color: var(--card-bg);
    border-radius: 0.75rem;
    box-shadow: var(--shadow-light);
    border: 1px solid var(--border-color);
    overflow: hidden;
    transition: all 0.2s ease;
}

.card:hover {
    box-shadow: var(--shadow-medium);
}

.card-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--card-bg);
}

.card-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-color);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-header h3 i {
    color: var(--primary-color);
}

.card-body {
    padding: 1.5rem;
}

/* 输入组样式 */
.input-group {
    margin-bottom: 1.5rem;
}

.input-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-color);
    margin-bottom: 0.5rem;
}

/* 按钮组样式 */
.button-group {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

/* 结果容器样式 */
.result-container {
    margin-top: 1.5rem;
}

.result-container h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.result-container h4 i {
    color: var(--primary-color);
}

.result-content {
    background-color: var(--background-color);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 1rem;
    min-height: 100px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.875rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: var(--text-color);
}

/* 表单元素样式 */
textarea {
    width: 100%;
    min-height: 120px;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    background-color: var(--card-bg);
    color: var(--text-color);
    resize: vertical;
    font-size: 0.875rem;
    line-height: 1.5;
    transition: all 0.2s ease;
    font-family: inherit;
}

textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

textarea:hover {
    border-color: var(--primary-color);
}

input[type="text"],
input[type="password"] {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    background-color: var(--card-bg);
    color: var(--text-color);
    font-size: 0.875rem;
    transition: all 0.2s ease;
    font-family: inherit;
}

input[type="text"]:focus,
input[type="password"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

input[type="text"]:hover,
input[type="password"]:hover {
    border-color: var(--primary-color);
}

/* 下拉框样式 */
select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    background-color: var(--card-bg);
    color: var(--text-color);
    font-size: 0.875rem;
    transition: all 0.2s ease;
    cursor: pointer;
    font-family: inherit;
}

select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

select:hover {
    border-color: var(--primary-color);
}

/* 占位符样式 */
textarea::placeholder,
input[type="text"]::placeholder,
input[type="password"]::placeholder {
    color: var(--text-light);
    opacity: 1;
}

/* 按钮样式 */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    font-family: inherit;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-medium);
}

.btn-secondary {
    background-color: var(--border-color);
    color: var(--text-color);
}

.btn-secondary:hover {
    background-color: var(--text-light);
    color: white;
}

.btn-success {
    background-color: var(--success-color);
    color: white;
}

.btn-success:hover {
    background-color: #38a169;
}

.btn-danger {
    background-color: var(--error-color);
    color: white;
}

.btn-danger:hover {
    background-color: #e53e3e;
}

.btn-warning {
    background-color: var(--warning-color);
    color: white;
}

.btn-warning:hover {
    background-color: #dd6b20;
}

/* 兼容旧按钮样式 */
button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    background-color: var(--primary-color);
    color: white;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

button:hover {
    background-color: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-medium);
}

/* 状态项样式 */
.status-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.status-item:last-child {
    border-bottom: none;
}

.status-label {
    font-weight: 500;
    color: var(--text-light);
}

.status-value {
    font-weight: 600;
    color: var(--primary-color);
}

/* API配置区域样式 */
.api-config {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 15px;
    margin: 10px 0;
    background: var(--card-bg);
    transition: all 0.3s ease;
}

.api-config:hover {
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.1);
}

/* 复选框组样式 */
.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 8px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-color);
    transition: color 0.3s ease;
}

.checkbox-item:hover {
    color: var(--primary-color);
}

.checkbox-item input[type="checkbox"] {
    margin-right: 8px;
    width: 16px;
    height: 16px;
    accent-color: var(--primary-color);
    cursor: pointer;
}

.checkbox-item span {
    user-select: none;
}

/* 智能对话样式 */
.chat-container {
    display: flex;
    flex-direction: column;
    min-height: 400px;
    max-height: 80vh;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-color);
    margin-bottom: 15px;
    min-height: 300px;
    max-height: 70vh;
}

.chat-message {
    margin-bottom: 15px;
    padding: 10px;
    border-radius: 8px;
    max-width: 80%;
}

.chat-message.user {
    background: var(--primary-color);
    color: white;
    margin-left: auto;
    text-align: right;
}

.chat-message.assistant {
    background: var(--card-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.chat-message .message-content {
    line-height: 1.5;
    word-wrap: break-word;
}

.chat-message .message-time {
    font-size: 12px;
    opacity: 0.7;
    margin-top: 5px;
}

.chat-input-container {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.chat-input {
    flex: 1;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    background: var(--input-bg);
    color: var(--text-color);
}

.chat-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.1);
}

.chat-send-btn {
    padding: 10px 15px;
    min-width: 50px;
}

.chat-actions {
    display: flex;
    justify-content: flex-end;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* 页面描述样式 */
.page-description {
    color: var(--text-light);
    margin: 0;
    font-size: 0.875rem;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    
    .sidebar.collapsed {
        width: 100%;
        height: 60px;
        overflow: hidden;
    }
    
    .sidebar-nav {
        flex-direction: row;
        overflow-x: auto;
    }
    
    .content-grid {
        grid-template-columns: 1fr;
    }
    
    .main-content {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .card {
        margin: 0.5rem 0;
    }
    
    .button-group {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
}

/* 文件控制样式 */
.file-control {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
    padding: 10px;
    background-color: var(--card-background);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.file-control span {
    color: var(--text-color);
    font-size: 14px;
    padding: 5px 10px;
    background-color: var(--background-color);
    border-radius: 4px;
    border: 1px solid var(--border-color);
    min-width: 200px;
    text-align: center;
}

.file-control button {
    margin-bottom: 0;
    padding: 8px 16px;
    font-size: 14px;
}

.filter-control {
    margin-bottom: 15px;
    padding: 15px;
    background-color: var(--card-background);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.filter-control > label {
    display: block;
    font-weight: 500;
    color: var(--text-color);
    margin-bottom: 10px;
    font-size: 15px;
}

.filter-control label {
    font-weight: 500;
    color: var(--text-color);
    margin-right: 10px;
}

.filter-control input[type="checkbox"] {
    margin-right: 8px;
    margin-left: 0;
    transform: scale(1.1);
    accent-color: var(--primary-color);
}

.filter-control input[type="checkbox"] + label,
.filter-control label + input[type="checkbox"] {
    margin-right: 15px;
    font-size: 14px;
    color: var(--text-color);
    cursor: pointer;
    user-select: none;
}

.checkbox-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 8px;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    font-size: 14px;
    color: var(--text-color);
    cursor: pointer;
    user-select: none;
    padding: 8px 12px;
    background-color: var(--card-background);
    border-radius: 6px;
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.checkbox-group label:hover {
    background-color: var(--background-color);
    border-color: var(--primary-color);
}

.checkbox-group input[type="checkbox"] {
    margin-right: 8px;
    margin-left: 0;
}

/* 进度条样式 */
.progress-bar {
    width: 100%;
    height: 10px;
    background-color: var(--border-color);
    border-radius: 5px;
    margin-bottom: 15px;
    overflow: hidden;
}

.progress {
    width: 0%;
    height: 100%;
    background-color: var(--primary-color);
    transition: width 0.3s ease;
}

/* 结果容器样式 */
.result-container {
    margin-top: 20px;
    padding: 15px;
    background-color: var(--background-color);
    border-radius: 5px;
    border: 1px solid var(--border-color);
}

.result-container h3 {
    margin-bottom: 10px;
    color: var(--primary-color);
}

/* 语言控制样式 */
.lang-control {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

/* 对话功能样式 */
.chat-container {
    margin-top: 30px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    background-color: var(--background-color);
}

.chat-messages {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 15px;
    background-color: var(--background-color);
}

.chat-message {
    margin-bottom: 15px;
    padding: 10px;
    border-radius: 6px;
}

.chat-message.user {
    background-color: var(--primary-color);
    color: white;
    margin-left: 20%;
    text-align: right;
}

.chat-message.assistant {
    background-color: var(--border-color);
    color: var(--text-color);
    margin-right: 20%;
}

.chat-message .message-role {
    font-weight: bold;
    font-size: 0.9em;
    margin-bottom: 5px;
    opacity: 0.8;
}

.chat-message .message-content {
    line-height: 1.5;
    white-space: pre-wrap;
}

.chat-input-area {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.chat-input-area textarea {
    flex: 1;
    min-height: 60px;
    max-height: 120px;
    resize: vertical;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-family: inherit;
    background-color: var(--background-color);
    color: var(--text-color);
}

.chat-input-area button {
    padding: 10px 20px;
    height: fit-content;
    white-space: nowrap;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .split-view {
        grid-template-columns: 1fr;
    }

    .tab-buttons {
        flex-direction: column;
    }

    .tab-btn {
        width: 100%;
    }
    
    .chat-input-area {
        flex-direction: column;
        align-items: stretch;
    }
    
    .chat-input-area button {
        margin-top: 10px;
    }
    
    .chat-message.user {
        margin-left: 10%;
    }
    
    .chat-message.assistant {
        margin-right: 10%;
    }
}

/* 动画效果 */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tab-content.active {
    animation: fadeIn 0.3s ease-out;
}

/* 配置管理样式 */
.config-section {
    background: var(--secondary-bg);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}

.config-section h3 {
    color: var(--accent-color);
    margin-bottom: 20px;
    font-size: 1.2em;
    border-bottom: 2px solid var(--accent-color);
    padding-bottom: 8px;
}

.config-group {
    margin-bottom: 25px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.config-group h4 {
    color: var(--text-color);
    margin-bottom: 15px;
    font-size: 1.1em;
    font-weight: 600;
}

.config-group label {
    display: block;
    color: var(--text-color);
    margin-bottom: 8px;
    font-weight: 500;
}

.config-group select,
.input-group input {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--secondary-bg);
    color: var(--text-color);
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.config-group select:focus,
.input-group input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.2);
}

.input-group {
    margin-bottom: 15px;
}

.input-group label {
    margin-bottom: 5px;
    font-size: 14px;
}

.config-actions {
    display: flex;
    gap: 15px;
    margin-top: 25px;
    flex-wrap: wrap;
}

.config-actions button {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    background: var(--accent-color);
    color: white;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px;
}

.config-actions button:hover {
    background: var(--button-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.config-actions button:active {
    background: var(--button-pressed);
    transform: translateY(0);
}

#load-config-btn {
    background: #28a745;
}

#load-config-btn:hover {
    background: #218838;
}

#test-config-btn {
    background: #ffc107;
    color: #212529;
}

#test-config-btn:hover {
    background: #e0a800;
}

/* 配置组显示/隐藏 */
.config-group.hidden {
    display: none;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .config-actions {
        flex-direction: column;
    }
    
    .config-actions button {
        width: 100%;
    }
    
    .config-section {
        padding: 15px;
    }
    
    /* 移动端智能对话优化 */
    .chat-container {
        min-height: 300px;
        max-height: 90vh;
    }
    
    .chat-messages {
        min-height: 200px;
        max-height: 80vh;
        padding: 10px;
    }
    
    .chat-message {
        max-width: 95%;
        padding: 8px;
        margin-bottom: 10px;
    }
    
    .chat-input-container {
        flex-direction: row;
        gap: 8px;
    }
    
    .chat-input {
        font-size: 16px; /* 防止iOS缩放 */
    }
}
